package com.lxq.LeetCode.rotatedDigits;

public class Solution {
    public static void main(String[] args) {
        System.out.println(rotatedDigits(10));
    }

    public static int rotatedDigits(int n) {
        int wrongNum = n / 10 * 3;
        if (n % 10 >= 3) {
            wrongNum++;
        }
        if (n % 10 >= 4) {
            wrongNum++;
        }
        if (n % 10 >= 7) {
            wrongNum++;
        }
        int N = n;
        int digit = 0;
        int[] digiNum = {2, 6, 18, 54};
        while (N >= 1) {
            digit++;
            wrongNum += digiNum[digit - 1];
            N = N / 10;
        }

        return n - wrongNum;
    }
}
